Skip to content

test: ignore stale AI agents init prompts during sample download#9102

Merged
vhvb1989 merged 9 commits into
mainfrom
fix/ai-agents-live-ignore-stale-init-prompt
Jul 14, 2026
Merged

test: ignore stale AI agents init prompts during sample download#9102
vhvb1989 merged 9 commits into
mainfrom
fix/ai-agents-live-ignore-stale-init-prompt

Conversation

@v1212

@v1212 v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #9101

Summary

  • Updates the AI agents Tier 2 live E2E console driver to ignore answered survey prompts once azd init progress appears after them.
  • Prevents false init stuck in prompt loop failures when survey leaves an answered starter/agent-template prompt visible on the PTY screen during sample download/copy.
  • Fails fast on invalid GitHub token / GitHub CLI authentication prompts instead of retrying into gh browser/device login in CI.

Root cause

  • The live test driver identifies the active interactive prompt by scanning the rendered virtual-terminal screen for prompt lines.
  • After selecting a starter template, survey can leave the answered ? select a starter template line on screen while azd init continues downloading and copying the sample.
  • In slower/timing-sensitive runs, the screen can contain both the stale prompt and later init progress such as Downloading sample from GitHub, azure.yaml, or src/....
  • The old driver treated that stale prompt as still active, retried prompt handling even though the CLI was no longer waiting for input, and eventually failed with a prompt-loop error.
  • PR live runs also showed that pipeline-provided GH_TOKEN / GITHUB_TOKEN can be invalid. Retrying without validating token state lets gh fall back to interactive auth prompts or fail later during sample adoption.
  • GitHub CLI device-login output can end on a non-? line, so the driver must classify auth/device-login lines explicitly instead of waiting for a survey prompt.

Fix details

  • activePrompt now treats answered prompts followed by init progress as stale.
  • Answered starter/agent-template prompts without active choice rows are ignored instead of re-dispatched.
  • GitHub CLI auth prompts and device-login lines are detected explicitly and fail with a clear token/auth error.
  • The live driver strips inherited GitHub token env vars, validates any candidate token before passing it to azd, and avoids poisoning later test modes with an unusable token.
  • phaseInitWithRetry was renamed to phaseInitWithTokenCheck to reflect that it now classifies token failures rather than retrying.
  • Unit coverage was added for stale prompt detection, later real prompts after progress, GitHub auth prompt classification, and non-? GitHub device-login lines.

Why this surfaced now

  • ci: associate AI agents live pipeline with main PRs #9039 did not introduce the driver bug; it associated the live pipeline with relevant PRs so /azp run azure-dev - live - ext - azure.ai.agents can start PR comment-triggered runs.
  • The PR-triggered path exposed pre-existing PTY/rendering timing races and token/auth retry behavior that did not consistently appear in earlier manual/main runs.

Validation

Local:

  • gofmt -w tests/e2e-live/console_test.go tests/e2e-live/tier2_live_test.go
  • go test -count=1 ./tests/e2e-live/
  • GOOS=linux GOARCH=amd64 GOTOOLCHAIN=go1.26.4 go fix -diff ./...
  • GOOS=linux GOARCH=amd64 GOTOOLCHAIN=go1.26.4 go test -c ./tests/e2e-live/

CI / live:

  • Public PR pipeline passed on latest commit 77a867d4: build 6552884.
  • All GitHub checks passed on latest commit 77a867d4.
  • All review threads are resolved.
  • Comment-triggered live pipeline passed on latest commit 77a867d4: build 6552933.
  • A second consecutive comment-triggered live pipeline passed on latest commit 77a867d4: build 6552980.
  • Earlier successful live runs before later review-fix commits: 6551457 and 6551564.
  • Earlier failing runs that motivated fixes: 6551005 (stale answered template prompt), 6551073 (invalid GitHub token retry entered gh browser auth), and 6552245 (invalid inherited token reused in the next mode).

Copilot AI review requested due to automatic review settings July 13, 2026 02:27
@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Azure AI Agents Tier 2 live E2E console driver to avoid misclassifying already-answered Survey prompts as “active” when init progress output appears after them (e.g., during slower GitHub sample downloads), preventing false “prompt loop” failures.

Changes:

  • Extend prompt detection to ignore ? prompt lines when init progress output is present after the prompt.
  • Add init-progress heuristics that recognize GitHub sample download/copy/adoption output lines.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new hasInitProgressAfterPrompt trips the required lint / go-fix check, which is currently red and blocking merge. The file is build-tagged //go:build linux, so go fix only flags it on Linux (a local Windows run passes, which is easy to miss). Running go fix ./... with GOOS=linux in cli/azd/extensions/azure.ai.agents rewrites the manual loop to slices.ContainsFunc and adds the slices import.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go
Copilot AI review requested due to automatic review settings July 13, 2026 03:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go Outdated

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The go-fix rewrite I flagged is in: hasInitProgressAfterPrompt now uses slices.ContainsFunc with the slices import, and the required lint / go-fix check is green. Approving to clear my earlier comment.

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings July 13, 2026 03:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit adds isAnsweredTemplatePrompt and two focused unit tests for activePrompt (answered select without choices, active select with choices). The lint / go-fix check I flagged earlier is green. Re-approving against the current HEAD (2d1c700).

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings July 13, 2026 08:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings July 13, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/tier2_live_test.go Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/tier2_live_test.go Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@v1212

v1212 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

/azp run azure-dev - live - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the latest test-driver changes against 77a867d. The runner now strips unusable GITHUB_TOKEN/GH_TOKEN from its env and validates a token with gh auth status before using it, and init still fails fast when it reaches an interactive GitHub CLI auth prompt, including the non-? device-login line. The withoutGitHubTokenEnv helper allocates a fresh slice instead of aliasing os.Environ(). Covered by the new activePrompt and isGitHubAuthPrompt unit tests. Re-approving against the current HEAD.

@vhvb1989 vhvb1989 enabled auto-merge (squash) July 13, 2026 18:54
@vhvb1989

Copy link
Copy Markdown
Member

/check-enforcer evaluate

Comment thread cli/azd/extensions/azure.ai.agents/tests/e2e-live/console_test.go

@trangevi trangevi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided that my questions don't need to be considered blocking

@vhvb1989 vhvb1989 merged commit 7eed332 into main Jul 14, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live AI agents E2E can misread stale init prompt during sample download

5 participants